<template>
  <div class="login">
    <div class="login-box">
      <el-form label-width="100" label-position="top">
        <el-form-item label="用户名">
          <el-input v-model="user.userNmae" />
        </el-form-item>
        <el-form-item label="密码">
          <el-input v-model="user.passWord" type="password" />
        </el-form-item>
      </el-form>
      <div class="login-button">
        <el-button @click="doLogin(false)"> 登录 </el-button>
        <el-button @click="doLogin('reset')"> 重置 </el-button>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
const router = inject('$router')
import { ref, inject } from 'vue'
interface Person {
  userNmae: string
  passWord: number
}
const user: Person = ref({
  userNmae: 'userNmae',
  passWord: 123456789,
})

const doLogin = (type) => {
  const Token: any = Math.random()
  localStorage.setItem('user', Token)

  if (!type) {
    console.log('Login', router)
    router.push('/')
    return
  }
  user.value = {}
}
</script>

<style lang="scss" scoped>
.login {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;

  .login-box {
    height: 200px;
    width: 500px;
    padding: 40px;
    border: 1px solid skyblue;
    border-radius: 5px;

    .login-button {
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
}
</style>
